<script>
    export let name = "默认的名称"; // 卡牌名称
    export let type = "life"; // 卡牌类型
    export let image = "/bg1.png"; // 卡牌图片
    export let description = ""; // 卡牌描述
    export let actionCost = 0;

    const typeColors = {
        'tool': '#FFD700',
        'life': '#FF4444',
        'buff': '#4CAF50',
        'attack': '#FF8C00',
        'trash': '#808080'
    };

    const typeNames = {
        'tool': '工具',
        'life': '生命',
        'buff': '增益',
        'attack': '攻击',
        'trash': '垃圾'
    };

    // 获取发光颜色
    $: glowColor = typeColors[type] || '#808080';
</script>

<div class="card" style="--glow-color: {glowColor}">
    <div class="card-cost">{actionCost}</div>
    <div class="card-image">
        <img src={image} alt={name} />
    </div>
    <div class="card-content">
        <h3 class="card-name">{name}</h3>
        <div 
            class="card-type"
            style="background-color: {glowColor}"
        >
            {typeNames[type] || '未知'}
        </div>
        <p class="card-description">{description}</p>
    </div>
</div>

<style>
    .card {
        width: 200px;
        height: 300px;
        background: #2d2d2d;
        border-radius: 10px;
        position: relative;
        color: white;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
        transition: all 0.3s ease;
        overflow: hidden;
        cursor: pointer;
    }

    .card:hover {
        transform: translateY(-5px) scale(1.02);
        box-shadow: 
            0 0 15px var(--glow-color),
            0 0 30px rgba(var(--glow-color), 0.3);
    }

    .card-cost {
        position: absolute;
        top: 10px;
        left: 10px;
        width: 30px;
        height: 30px;
        background: #fff;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: bold;
        color: #2d2d2d;
        z-index: 1;
    }

    .card-image {
        width: 100%;
        height: 140px;
        overflow: hidden;
    }

    .card-image img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .card-content {
        padding: 15px;
    }

    .card-name {
        margin: 0 0 8px 0;
        font-size: 1.2em;
    }

    .card-type {
        display: inline-block;
        padding: 4px 8px;
        border-radius: 4px;
        font-size: 0.9em;
        margin-bottom: 10px;
    }

    .card-description {
        font-size: 0.9em;
        line-height: 1.4;
        margin: 0;
        color: #ccc;
    }
</style> 